package com.nce.entity;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 微博
 * 
 * @author GT
 */
@Entity
@Table(name = "mblog")
// 默认的缓存策略.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Mblog extends BaseNews {

	private static final long serialVersionUID = 7589108853815428562L;
	/*
	 CREATE TABLE `Mblog` (
 `id` int(11) NOT NULL auto_increment,
 `uid` mediumint(9) default NULL,#文章所属的用户
 `tm_post` datetime default NULL,#发文时间
  `content` text, # 内容
  `url` varchar(255) default NULL,#该微博的url、
  `tm_spider` timestamp NULL default CURRENT_TIMESTAMP,
  `Is_New` varchar(255) default NULL,#新文章标志
 `Has_Export` varchar(255) default NULL,#导出标志
  
 `source_site` varchar(255) default NULL,#发文媒体 新浪/腾讯
 `author_id` varchar(255) default NULL, #作者的微博id
 `author` varchar(255) default NULL, # 作者名（微博名）
 `author_city` varchar(255) default NULL,#作者所在城市
 `author_info` varchar(255) default NULL,#作者自我描述信息
 `guanzhu_cnt` mediumint(9) default NULL,#作者关注数
 `fans_cnt` mediumint(9) default NULL,#作者发文数
 `article_cnt` mediumint(9) default NULL,#作者文章数  
 `from_device` varchar(255) default NULL,#来自XX
 `forword_cnt` mediumint(9) default NULL,#转发数
 `reserved_cnt` mediumint(9) default NULL,#收藏数
 `remark_cnt` mediumint(9) default NULL,#评论数
 `article_type` varchar(255) default NULL,

 PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
	 */

	private String sourceSite;
	private String authorId;
	private String author;
	private String authorCity;
	private String authorInfo;
	private Long guanzhuCnt;
	private Long fansCnt;
	private Long articleCnt;
	private String fromDevice;
	private Long forwordCnt;
	private Long reservedCnt;
	private Long remarkCnt;
	private String articleType;

	public String getSourceSite() {
		return sourceSite;
	}

	public void setSourceSite(String sourceSite) {
		this.sourceSite = sourceSite;
	}

	public String getAuthorId() {
		return authorId;
	}

	public void setAuthorId(String authorId) {
		this.authorId = authorId;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getAuthorCity() {
		return authorCity;
	}

	public void setAuthorCity(String authorCity) {
		this.authorCity = authorCity;
	}

	public String getAuthorInfo() {
		return authorInfo;
	}

	public void setAuthorInfo(String authorInfo) {
		this.authorInfo = authorInfo;
	}

	public Long getGuanzhuCnt() {
		return guanzhuCnt;
	}

	public void setGuanzhuCnt(Long guanzhuCnt) {
		this.guanzhuCnt = guanzhuCnt;
	}

	public Long getFansCnt() {
		return fansCnt;
	}

	public void setFansCnt(Long fansCnt) {
		this.fansCnt = fansCnt;
	}

	public Long getArticleCnt() {
		return articleCnt;
	}

	public void setArticleCnt(Long articleCnt) {
		this.articleCnt = articleCnt;
	}

	public String getFromDevice() {
		return fromDevice;
	}

	public void setFromDevice(String fromDevice) {
		this.fromDevice = fromDevice;
	}

	public Long getForwordCnt() {
		return forwordCnt;
	}

	public void setForwordCnt(Long forwordCnt) {
		this.forwordCnt = forwordCnt;
	}

	public Long getReservedCnt() {
		return reservedCnt;
	}

	public void setReservedCnt(Long reservedCnt) {
		this.reservedCnt = reservedCnt;
	}

	public Long getRemarkCnt() {
		return remarkCnt;
	}

	public void setRemarkCnt(Long remarkCnt) {
		this.remarkCnt = remarkCnt;
	}

	public String getArticleType() {
		return articleType;
	}

	public void setArticleType(String articleType) {
		this.articleType = articleType;
	}
	
	
	
	public String formatForExport(){
//			第一部分：标题（点击超链接进入该条新闻原始页面），发文媒体，发文时间，
//			第二部分：新闻内容摘要，转发数量（XX条相同新闻,）
		StringBuilder sb = new StringBuilder();	
		sb.append("\"").append(getAuthor()).append("\",");
		sb.append("\"").append(getUrl()).append("\",");
		sb.append("\"").append(getContent()).append("\",");
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		sb.append("\"").append(df.format(getTmPost())).append("\",");
		sb.append("\"").append(getSourceSite()).append("\",");
		sb.append(getForwordCnt()).append(",");
		sb.append(getReservedCnt()).append(",");
		sb.append(getRemarkCnt()).append(",");
		sb.append("\r\n");
		return sb.toString();
		
	}

	@Override
	public String toString() {
		return "Mblog [sourceSite=" + sourceSite + ", authorId=" + authorId
				+ ", author=" + author + ", authorCity=" + authorCity
				+ ", authorInfo=" + authorInfo + ", guanzhuCnt=" + guanzhuCnt
				+ ", fansCnt=" + fansCnt + ", articleCnt=" + articleCnt
				+ ", fromDevice=" + fromDevice + ", forwordCnt=" + forwordCnt
				+ ", reservedCnt=" + reservedCnt + ", remarkCnt=" + remarkCnt
				+ ", articleType=" + articleType + ", getTitle()=" + getTitle()
				+ ", getContent()=" + getContent() + ", getUrl()=" + getUrl()
				+ ", getForumName()=" + getForumName() + ", getUser()="
				+ getUser() + ", getTmSpider()=" + getTmSpider()
				+ ", getIsNew()=" + getIsNew() + ", getHasExport()="
				+ getHasExport() + ", getId()=" + getId() + ", getClass()="
				+ getClass() + ", hashCode()=" + hashCode() + ", toString()="
				+ super.toString() + "]";
	}

	
	
}
